#pragma once
#include <QString>
#include "json_trans.h"
#include "common_data.h"

namespace plate {
	struct StackTypeInfo {
		int type;
		QString name;
		int ceng;
		int max;
		void clear()
		{
			type = 0;
			name.clear();
			ceng = 0;
			max = 0;
		}
	};
	struct PlateInfo {
		QString id;
		int di;	// di校验值
		QString alg;	// 算法指针
		int dirEven;	// 码垛方向
		int dirOdd;
		Position base;	// 托盘中心点坐标
		Size rang;		// 托盘码垛空间范围
	};

	json_struct(AlgStackInfo,
		mapping(int, id);
	mapping(QString, name);
	mapping(int, ceng);
	mapping(int, max);
	prop(&id, &name, &ceng, &max);
	);

	json_struct(AlgCalParam,
		mapping(int, num);
	mapping(int, grabed);
	prop(&num, &grabed);
	);
	/*算法结果：本次的最大抓取数量*/
	json_struct(StackAlgResult,
		mapping(int, num);
	prop(&num);
	);

	structJ(PlateArriveInfo,
		mapping(QString, robNo);
	mapping(int, num);
	mapping(QString, placeNo);
	mapping(QString, plateId);
	prop(&robNo, &num, &placeNo, &plateId);
	);
	structJ(PlateMoveInfo,
		mapping(QString, robNo);
	mapping(QString, placeNo);
	mapping(QString, plateId);
	prop(&robNo, &placeNo, &plateId);
	);

	json_struct(PlateStateJ,
		mapping(QString, id);
	mapping(bool, plate);
	mapping(int, num);
	mapping(SkuInfoJ, sku);
	mapping(AlgStackInfo, stack);
	prop(&id, &plate, &num, &sku, &stack);
	);
	struct PlateState {
		bool plate;	// 托盘是否到位
		int num;	// 物料数量
		SkuInfo sku;
		StackTypeInfo stack;
		void clear()
		{
			plate = false;
			num = 0;
			sku.clear();
			stack.clear();
		}
		void TransFormPlateStateJ(const PlateStateJ& in)
		{
			plate = in.plate();
			num = in.num();
			sku.TransfromSkuInfoJ(in.sku());
			stack.ceng = in.stack().ceng();
			stack.max = in.stack().max();
			stack.name = in.stack().name();
			stack.type = in.stack().id();
		}
		PlateStateJ TranToPlateStateJ()
		{
			PlateStateJ out = {};
			out.plate = plate;
			out.num = num;
			out.sku = sku.TransToSkuInfoJ();
			out.stack().ceng = stack.ceng;
			out.stack().max() = stack.max;
			out.stack().name() = stack.name;
			out.stack().id() = stack.type;
			return out;
		}

	};

	enum class StackPlateCmd {
		stackplate_get_plateState = 1,

	};

}


